/**
 *文章列表数据的接口模块
 */

import request from '@/utils/request'

// 获取频道的文章列表 并导出
export const getArticles = params => {
  return request({
    method: 'GET',
    url: 'http://toutiao-app.itheima.net/v1_1/articles',
    params
  })
}

// 获取 文章详情 的接口
export const getArticleById = articleId => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${articleId}`
  })
}

// 获取 收藏文章 的接口
export const addCollect = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}

// 获取 取消文章收藏 的接口
export const deleteCollect = target => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${target}`
  })
}

/***
 * 获取 对文章点赞 的接口
 */
export const addLike = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target
    }
  })
}

/*
 **获取 取消对文章点赞 的接口
 */
export const deleteLike = target => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${target}`
  })
}
